<template>
  <div class="foreign">
    <div v-for="(item, index) in galleryData" :key="index" @click="goRouter(item)">
      <div class="for-img">
        <img :src="item.img_list[0].response" alt />
      </div>
      <div class="for-font">
        <div class="for-title">{{item.name}}</div>
        <div class="for-text">{{item.summary}}</div>
        <div class="for-icon">
          <div>
            <i></i>
            <span>{{item.views}}</span>
          </div>

          <div>
            <i></i>
            <span>{{item.collect}}</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { galleryAddViews } from "@/api/home/api";
export default {
  props: ["galleryData"],
  methods: {
    goRouter({ id }) {
      galleryAddViews({ id }).then(res => {
        let data = res.data;
        data.dataList.forEach((item, index, arr) => {
          arr[index].img_list = JSON.parse(arr[index].img_list);
        });
        let galleryData=JSON.stringify(data.dataList[0])
        this. $router.push({ path: '/home/news',query: { galleryData } })
      });
    }
  }
};
</script>

<style scoped>
.foreign {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
}
.foreign > div {
  cursor: pointer;
  width: 25%;
  margin-bottom: 25px;
  border: 1px solid #fff;
  box-sizing: border-box;
  padding: 10px 10px 0 10px;
}
.foreign > div:hover {
  border: 1px solid rgb(0, 0, 0);
}
.foreign > div > div {
  margin-right: 18px;
}
.for-img {
  width: 100%;
  height: 206px;
  margin-bottom: 14px;
}
.for-font {
  width: 100%;
}
.for-img img {
  width: 100%;
  height: 100%;
}
.for-title {
  cursor: pointer;
  color: #424034;
  font-size: 14px;
  line-height: 22px;
  font-weight: bold;
}
.for-title:hover {
  color: #0dbd95;
}
.for-text {
  cursor: pointer;
  color: #707070;
  line-height: 16px;
  font-size: 12px;

  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}
.for-text:hover {
  color: #000;
}
.for-icon {
  display: flex;
}
.for-icon {
  height: 20px;
  color: #b2b1b1;
  font-size: 12px;
  border-bottom: 1px solid #e5e5e5;
  padding-bottom: 20px;
  padding-top: 8px;
}
.for-icon > div {
  margin-right: 20px;
}
.for-icon > div:first-child > i {
  padding: 2px 12px;
  margin-right: 4px;
  background: url("../assets/icon/spirit.png") 0 -173px;
}
.for-icon > div:nth-child(2) > i {
  padding: 2px 12px;
  margin-right: 4px;
  background: url("../assets/icon/spirit.png") 0 -192px;
}
.for-icon > div:last-child > i {
  padding: 2px 12px;
  margin-right: 4px;
  background: url("../assets/icon/spirit.png") 0 -216px;
}
</style>